import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    // {
    //     // 404页面
    //     path: '*',
    //     redirect: '/login',
    //     meta: {
    //         needLogin: true //需要加校检判断的路由
    //     },
    // },
    {
        path: '/',
        redirect: '/login',
        meta: {
            needLogin: true //需要加校检判断的路由
        },

    },
    {
        path: '/home',//path设为空，就是默认展示+的看板
        name: '首页',
        component: () => import('@/views/layou/index'),

    },
    {
        path: '/login',//path设为空，就是默认展示+的看板
        name: '登录',
        component: () => import('@/views/login/index'),
        meta: { title: '百度营销-登录' } // 添加title属性

    },
    {
        path: '/register',//path设为空，就是默认展示+的看板
        name: '注册',
        component: () => import('@/views/login/register'),
        meta: { title: '百度营销-注册' } // 添加title属性
    },
    {
        path: '/caiwuPage',//path设为空，就是默认展示+的看板
        name: '财务信息',
        component: () => import('@/views/caiwu/caiwuPage'),
        meta: { title: '百度营销-财务中心' } // 添加title属性
    },
    {
        path: '/jiaofeiPage',//path设为空，就是默认展示+的看板
        name: '付款费用',
        component: () => import('@/views/jiaofei/jiaofeiPage'),
        meta: { title: '百度营销-财务中心' } // 添加title属性
    },
    {
        path: '/zhanghu',//path设为空，就是默认展示+的看板
        name: '账户管理',
        component: () => import('@/views/zhanghu/caiwuPage'),
        meta: { title: '百度营销-账户中心' } // 添加title属性
    },

    {
        path: '/jiluPage',//path设为空，就是默认展示+的看板
        name: '付款记录',
        component: () => import('@/views/jiaofei/jiluPage'),
        meta: { title: '百度营销-财务中心' } // 添加title属性
    },
    {
        path: '/fc',//path设为空，就是默认展示+的看板
        name: '搜索推广',
        component: () => import('@/views/fc/index.vue'),
        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
        children:[

            {
                path: 'datacenter',//path设为空，就是默认展示+的看板
                name: '数据报告',
                meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                component: () => import('@/views/fc/datacenter/index'),
                children:[
                    {
                        path: '/',//path设为空，就是默认展示+的看板
                        name: '账户报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/account'),
                    },
                    {
                        path: '/account',//path设为空，就是默认展示+的看板
                        name: '账户报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/account'),
                    },
                    {
                        path: '/campaign',//path设为空，就是默认展示+的看板
                        name: '计划报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/campaign'),
                    },
                    {
                        path: '/adgroup',//path设为空，就是默认展示+的看板
                        name: '单元报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/adgroup'),
                    },
                    {
                        path: '/keyword',//path设为空，就是默认展示+的看板
                        name: '关键词报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/keyword'),
                    },
                    {
                        path: '/queryword',//path设为空，就是默认展示+的看板
                        name: '搜索词报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/queryword'),
                    },
                    {
                        path: '/commodity',//path设为空，就是默认展示+的看板
                        name: '商品报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/commodity'),
                    },
                    {
                        path: '/crowd',//path设为空，就是默认展示+的看板
                        name: '人群报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/crowd'),
                    },
                    {
                        path: '/creative',//path设为空，就是默认展示+的看板
                        name: '创意报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/creative'),
                    },
                    {
                        path: '/creativeComponent',//path设为空，就是默认展示+的看板
                        name: '创意组件报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/creativeComponent'),
                    },
                    {
                        path: '/styles',//path设为空，就是默认展示+的看板
                        name: '高级样式报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/styles'),
                    },
                    {
                        path: '/video',//path设为空，就是默认展示+的看板
                        name: '视频报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/video'),
                    },
                    {
                        path: '/image',//path设为空，就是默认展示+的看板
                        name: '图片报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/image'),
                    },
                    {
                        path: '/landingPage',//path设为空，就是默认展示+的看板
                        name: '落地页报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/landingPage'),
                    },
                    {
                        path: '/vistorDetail',//path设为空，就是默认展示+的看板
                        name: '访客明细',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/vistorDetail'),
                    },
                    {
                        path: '/insight',//path设为空，就是默认展示+的看板
                        name: '数据简报',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/insight'),
                    },
                    {
                        path: '/program',//path设为空，就是默认展示+的看板
                        name: '小程序报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/program'),
                    },
                    {
                        path: '/realTime',//path设为空，就是默认展示+的看板
                        name: '实时报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/realTime'),
                    },
                    {
                        path: '/invalidClick',//path设为空，就是默认展示+的看板
                        name: '无效点击报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/invalidClick'),
                    },

                    {
                        path: '/custom',//path设为空，就是默认展示+的看板
                        name: '数据万花筒',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/custom'),
                    },
                    {
                        path: '/store',//path设为空，就是默认展示+的看板
                        name: '本地店铺报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/store'),
                    },
                    {
                        path: '/liftBudgetReport',//path设为空，就是默认展示+的看板
                        name: '一键起量报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/liftBudgetReport'),
                    },
                    {
                        path: '/ocpc',//path设为空，就是默认展示+的看板
                        name: 'oCPC报告',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,

                        component: () => import('@/views/fc/datacenter/ocpc'),
                    },
                ]
            },
            {
                path: 'managecenter',//path设为空，就是默认展示+的看板
                name: '推广管理',
                meta: { name:'推广管理' },
                component: () => import('@/views/fc/managecenter/index'),
                children:[
                    {
                        path: '/managecenter/adgroups',//path设为空，就是默认展示+的看板
                        name: '单元',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/adgroups'),
                    },
                    {
                        path: '/managecenter/campaigns',//path设为空，就是默认展示+的看板
                        name: '计划',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/campaigns'),
                    },
                    {
                        path: '/managecenter/projects',//path设为空，就是默认展示+的看板
                        name: '项目',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/projects'),
                    },
                    {
                        path: '/managecenter/optimizecenter',//path设为空，就是默认展示+的看板
                        name: '优化中心',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/optimizecenter'),
                    },
                    {
                        path: '/managecenter/keyword',//path设为空，就是默认展示+的看板
                        name: '关键词',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/keyword'),
                    },
                    {
                        path: '/managecenter/crowd',//path设为空，就是默认展示+的看板
                        name: '人群',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/crowd'),
                    },
                    {
                        path: '/managecenter/textUser',//path设为空，就是默认展示+的看板
                        name: '创意组件',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/textUser'),

                    },
                    {
                        path: '/managecenter/overview',//path设为空，就是默认展示+的看板
                        name: '账户概括',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/overview'),
                    },
                    {
                        path: '/managecenter/campaignSettings',//path设为空，就是默认展示+的看板
                        name: '计划设置',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/campaignSettings'),
                    },
                    {
                        path: '/managecenter/settings',//path设为空，就是默认展示+的看板
                        name: '账户设置',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/settings'),
                    },
                    {
                        path: '/managecenter/creativesvideos',//path设为空，就是默认展示+的看板
                        name: '创意',
                        meta: { title: '百度营销-搜索推广' } ,// 添加title属性,
                        component: () => import('@/views/fc/managecenter/creativesvideos'),
                    },
                    ]
            }
        ]
    },


]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})
router.beforeEach((to, from, next) => {
    // 动态设置页面标题
    document.title = to.meta.title || '默认标题';
    next();
});
export default router
